package mirfordevoservice;


import mirfordevoservice.config_entity.cache.CacheManager;
import mirfordevoservice.system.service.MainService;
import mirfordevoservice.system.GameCenter.DataCenter;
import mirfordevoservice.system.gamethreadpool.ThreadPoolManager;
import mirfordevoservice.system.listener.SocketAliveWatcher;

import java.io.IOException;

import static mirfordevoservice.system.contasnt.GameConstant.CacheCenter.PROTOCOL_CONFIG_CACHE;

/**
 * Created by Heart!
 *
 * @Author ZhangChaoJian
 * @Date 2018/3/14.19:50
 * Wants More Then Try Hard More!
 */
public class ServiceMainBootStrap {
    /**
     * 游戏服务器启动程序
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        CacheManager.getInstance().initCacheForGame();
        if (PROTOCOL_CONFIG_CACHE.size() == 0) {
            System.err.println("找不到协议配置...启动服务器失败");
            System.exit(0);
        }
        DataCenter.getInstance();//启动数据持久层
        ThreadPoolManager.threadPoolManager.execute(SocketAliveWatcher.getInstance());//开启会话监听器
        /**
         * 此进程需放在最后
         */
        MainService.getINSTANCE().startServer();//启动服务器
    }
}
